﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!-- Resource dictionary entries should be defined here. -->
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Colors.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type CheckBox}">
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="Foreground">
            <Setter.Value>
                <SolidColorBrush Color="{StaticResource Application_CheckBox_Foreground}"/>
            </Setter.Value>
        </Setter>
        <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=CheckBoxTemplate, TypeInTargetAssembly={x:Type CheckBox}}}"/>
    </Style>

    <ControlTemplate x:Key="{ComponentResourceKey ResourceId=CheckBoxTemplate, TypeInTargetAssembly={x:Type CheckBox}}" TargetType="{x:Type CheckBox}">
        <Grid Background="Transparent">
    		<Grid.ColumnDefinitions>
    			<ColumnDefinition Width="15"/>
    			<ColumnDefinition Width="*"/>
    		</Grid.ColumnDefinitions>
    		<VisualStateManager.VisualStateGroups>
    			<VisualStateGroup x:Name="CommonStates">
    				<VisualStateGroup.Transitions>
    					<VisualTransition From="MouseOver" GeneratedDuration="0:0:0.4" To="Normal"/>
    					<VisualTransition From="Pressed" GeneratedDuration="0:0:0.2"/>
    					<VisualTransition GeneratedDuration="0:0:0.2" To="Pressed"/>
    					<VisualTransition From="Normal" GeneratedDuration="0:0:0.3" To="MouseOver"/>
    				</VisualStateGroup.Transitions>
    				<VisualState x:Name="Normal" />
    				<VisualState x:Name="MouseOver">
    					<Storyboard>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_CheckBox_Background_Move}"/>
    						</ColorAnimationUsingKeyFrames>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_CheckBox_BorderBrush_Move}"/>
    						</ColorAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    				<VisualState x:Name="Pressed">
    					<Storyboard>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_CheckBox_Background_Pressed}"/>
    						</ColorAnimationUsingKeyFrames>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_CheckBox_BorderBrush_Pressed}"/>
    						</ColorAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    				<VisualState x:Name="Disabled" >
    					<Storyboard>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_CheckBox_BorderBrush_Disabled}"/>
    						</ColorAnimationUsingKeyFrames>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="Border">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_CheckBox_Background_Disabled}"/>
    						</ColorAnimationUsingKeyFrames>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="CheckMark">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_CheckBox_Foreground_Disabled}"/>
    						</ColorAnimationUsingKeyFrames>
    						<ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="InderminateMark">
    							<EasingColorKeyFrame KeyTime="0" Value="{StaticResource Application_CheckBox_Foreground_Disabled}"/>
    						</ColorAnimationUsingKeyFrames>
    						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="Disable">
    							<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
    						</ObjectAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="CheckStates">
    				<VisualState x:Name="Checked">
    					<Storyboard>
    						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="CheckMark">
    							<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
    						</ObjectAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    				<VisualState x:Name="Unchecked" />
    				<VisualState x:Name="Indeterminate">
    					<Storyboard>
    						<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="InderminateMark">
    							<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
    						</ObjectAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="ValidationStates">
    				<VisualState x:Name="Valid"/>
    				<VisualState x:Name="InvalidFocused"/>
    				<VisualState x:Name="InvalidUnfocused"/>
    			</VisualStateGroup>
    			<VisualStateGroup x:Name="FocusStates">
    				<VisualState x:Name="Unfocused"/>
    				<VisualState x:Name="Focused">
    					<Storyboard AutoReverse="True" RepeatBehavior="Forever">
    						<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="FocusBorder">
    							<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
    							<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.5"/>
    						</DoubleAnimationUsingKeyFrames>
    					</Storyboard>
    				</VisualState>
    			</VisualStateGroup>
    		</VisualStateManager.VisualStateGroups>
    		<Grid>
    			<Border x:Name="Border" Width="13" Height="13" CornerRadius="0" BorderThickness="1">
    				<Border.BorderBrush>
    					<SolidColorBrush Color="{StaticResource Application_CheckBox_BorderBrush}"/>
    				</Border.BorderBrush>
    				<Border.Background>
    					<SolidColorBrush Color="{StaticResource Application_CheckBox_Background}"/>
    				</Border.Background>
    				<Grid VerticalAlignment="Stretch">
    					<Path Visibility="Collapsed" Width="7" Height="7" x:Name="CheckMark" SnapsToDevicePixels="False" StrokeThickness="2" 
                              Data="M 0 0 L 7 7 M 0 7 L 7 0">
    						<Path.Stroke>
    							<SolidColorBrush Color="{StaticResource Application_CheckBox_Foreground}" />
    						</Path.Stroke>
    					</Path>
    					<Path Visibility="Collapsed" Width="7" Height="7" x:Name="InderminateMark" SnapsToDevicePixels="False" StrokeThickness="2" 
                              Data="M 0 7 L 7 0">
    						<Path.Stroke>
    							<SolidColorBrush Color="{StaticResource Application_CheckBox_Foreground}" />
    						</Path.Stroke>
    					</Path>
    				</Grid>
    			</Border>
    			<Border x:Name="FocusBorder" Width="13" Height="13" CornerRadius="0" BorderThickness="1" Opacity="0" Visibility="Visible">
    				<Border.BorderBrush>
    					<SolidColorBrush Color="{StaticResource Application_CheckBox_BorderBrush_Focus}"/>
    				</Border.BorderBrush>
    			</Border>
    			<Border x:Name="Disable" BorderThickness="1" Width="13" Height="13" Opacity="0.5" Visibility="Hidden">
    				<Border.Background>
    					<SolidColorBrush Color="{StaticResource Application_CheckBox_Background_Disabled}"/>
    				</Border.Background>
    				<Border.BorderBrush>
    					<SolidColorBrush Color="{StaticResource Application_CheckBox_BorderBrush_Disabled}"/>
    				</Border.BorderBrush>
    			</Border>
    		</Grid>
    		<ContentPresenter Margin="4,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" RecognizesAccessKey="True" Grid.Column="1" />
    	</Grid>
    </ControlTemplate>
</ResourceDictionary>